package com.hao.chatdemo.service;

import com.hao.chatdemo.pojo.Member;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @author 97472
 * @version 1.0
 * @date 2021/7/7 17:16
 */
@Service
public class MemberService {
    //不用数据库，直接将用户信息存在集合中
    private static final List<Member> MEMBERS = new ArrayList();
    //初始化
    static{
        MEMBERS.add(new Member("100","张三","zhangsan","123"));
        MEMBERS.add(new Member("101","李四","lisi","123"));
        MEMBERS.add(new Member("102","王五","wangwu","123"));
        MEMBERS.add(new Member("103","钱六","qianliu","123"));
    }

    private Member login(Member member){
        String username=member.getUsername();
        String password=member.getPassword();
        if(username == null|| password == null){
            return null;
        }
        for (Member ele:MEMBERS) {
            if (username.equals(ele.getUsername())&&password.equals(ele.getPassword())){
                return ele;
            }
        }
        return null;
    }
}
